home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4123 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  48 lines

  1. Path: howland.reston.ans.net!agate!parsons
  2. From: parsons@vouvray.CS.Berkeley.EDU (David C. Parsons)
  3. Newsgroups: comp.lang.c++
  4. Subject: Need help with derived class template
  5. Date: 28 Jan 1996 08:16:31 GMT
  6. Organization: University of California, Berkeley
  7. Message-ID: <4efbcv$ovo@agate.berkeley.edu>
  8. NNTP-Posting-Host: vouvray.cs.berkeley.edu
  9.  
  10. I am trying to write a class template which is derived from another
  11. class template, and unfortunately can't seem to get the syntax right.
  12. I've looked through the FAQ and my C++ books (Stroustrup, Lippman) and
  13. can't find a discussion of this anywhere.
  14.  
  15. The base class definition looks like this:
  16.  
  17.         template <class Type>
  18.         class Base { ... }
  19.  
  20. The compile errors arise from the derived class definition.  Here are
  21. the variations I've tried, and the errors they generate:
  22.  
  23. 1.      template <class Type>
  24.         class Derived : public Base { ... }
  25.  
  26.         ==> parse error before `{'
  27.  
  28. 2.      template <class Type>
  29.         class Derived : public Base<Type> { ... }
  30.  
  31.         ==> base class `Base<double>' has incomplete type
  32.  
  33. 3.      template <class Type>
  34.         class Derived<Type> : public Base<Type> { ... }
  35.  
  36.         ==> Internal compiler error.
  37.             Please submit a full bug report to `bug-g++@prep.ai.mit.edu'. 
  38.  
  39. Any suggestions?  Incidentally, the base class by itself works fine,
  40. and the inheritance works if I remove the templating (i.e. instantiate
  41. it "by hand" to a particular type).
  42.  
  43. Many thanks in advance --
  44.  
  45. David Parsons
  46. CS gradual student
  47. UC Berkeley
  48.